#include <stdio.h>
#include <signal.h>
#include <unistd.h>

static void handler1(int s);

static void handler2(int s); 

int main(void)
{
	int i, j;
	sigset_t set, oldset;
	struct sigaction act;

	act.sa_handler = handler1;
	act.sa_flags = 0;

	sigaction(SIGINT, &act, NULL);
	sigaction(SIGRTMIN+5, &act, NULL);

	sigemptyset(&set);
	sigaddset(&set, SIGINT);
	sigaddset(&set, SIGRTMIN+5);

	sigprocmask(SIG_BLOCK, &set, &oldset);

	for (i = 0; ; i++) {
		if (i == 5) {
			act.sa_handler = handler2;
			sigaction(SIGINT, &act, NULL);
			sigaction(SIGRTMIN+5, &act, NULL);
		}

		for (j = 0; j < 3; j++) {
			write(1, "*", 1);
			sleep(1);
		}
		printf("\n");

		sigsuspend(&oldset);
	}

	return 0;
}

static void handler1(int s)
{
	write(1, "!!!\n", 5);
}

static void handler2(int s)
{
	write(1, "???\n", 5);
}

